<template>
  <div class="fixed" v-dialogDrag>
    <div class="content el-dialog"
         style="padding:0">
      <div class="msgTop el-dialog__header">
        <span>电话回访</span>
        <i class="el-icon-close fr"
           style="cursor:pointer;line-height:40px;font-size:13px;"
           @click="cancelTransfer"></i>
      </div>
      <el-form :model="ruleForm"
               ref="ruleForm"
               class="demo-ruleForm"
               :rules="rules"
               style="padding:20px 20px 0 20px"
               label-width="100px">
        <el-form-item label="电话号码:"
                      label-width="100px"
                      prop="phone">
          <el-input type="tel"
                    v-model="ruleForm.phone"
                    style="width:80%"
                    :autosize="{ minRows: 3}"></el-input>
        </el-form-item>
        <el-form-item label-width="10px"
                      class="center">
          <el-button @click="submitForm('ruleForm')"
                     type="button"
                     class="el-button el-button--primary el-button--medium h30Btn ">拨号</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
// import { insertBatch } from '@/api/WorkOrderUrgeController'
export default {
  props: ['phoneNum'],
  data () {
    return {
      ruleForm: {
        phone: this.phoneNum
      },
      rules: {
        phone: [
          { required: true, message: '请输入电话号码', trigger: ['blur', 'change'] }
        ]
      }
    }
  },
  mounted () {
  },
  methods: {
    cancelTransfer () {
      this.$emit('phoneShow', false)
    },
    submitForm (formName) {
      window.parent.postMessage({
        event: 'EventMakeCall',
        'data': {
          "number": this.ruleForm.phone + "",
          "userData": { directCall: 0 }
        }
      }, '*')
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$emit('phoneShow', false)
          // let params = {
          //   content: this.ruleForm.menuDesc,
          //   userId: this.$store.state.userId,
          //   workOrderIdList: this.workOrderIdList
          // }
          // insertBatch(params).then(res => {
          //   if (res.data.retCode === 200) {
          //     this.$message({
          //       type: 'success',
          //       message: res.data.msg
          //     })
          //     this.$emit('phoneShow', false)
          //   } else {
          //     this.$message({
          //       type: 'error',
          //       message: res.data.msg
          //     })
          //   }
          // })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }
  }
}
</script>

<style scoped>
.center {
  text-align: center;
  font-size: 16px;
}

.paging-foot {
  padding: 10px 0;
}

</style>
